<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class CI_Sex_option_entity{
	var $id = 0;
	var $language_id = 0;
	var $code = 0;
	var $sex = "";
		
	function setId($input){
		$this->id=$input;
	}
	function setLanguageId($input){
		$this->language_id =$input;
	}
	function setCode($input){
		$this->code =$input;
	}
	function setSex($input){
		$this->sex =$input;
	}
	function getId(){
		return $this->id;
	}
	function getLanguageId(){
		return $this->language_id;
	}
	function getCode(){
		return $this->code;
	}
	function getSex(){
		return $this->sex;
	}
	
	function init($cmd, $input)
	{
		$ci=& get_instance();
		if($cmd == 'id'){
			$result = $ci->db->where('id',$input)->get(TBL_SEX_OPTION)->result();
		}else if($cmd == 'language_id'){
			$result = $ci->db->where('language_id',$input)->get(TBL_SEX_OPTION)->result();
		}else{
			return false;
		}
		if( !empty($result) ){
			$this->id = $result[0]->id;
			$this->language_id = $result[0]->language_id;
			$this->code = $result[0]->code;
			$this->sex = $result[0]->sex;
			return $this;
		}
		return false;
	}
	function getSexOptionByCode($code){
		$ci=& get_instance();
		$ci->db->where('code',$code);
		return $ci->db->get(TBL_SEX_OPTION)->result();
	}
	function getSexOptionList(){
		$ci=& get_instance();
		return $ci->db->get(TBL_SEX_OPTION)->result();
	}
	function getSexOptionListByLanguage($language_id){
		$ci=& get_instance();
		$ci->db->where('language_id',$language_id);
		return $ci->db->get(TBL_SEX_OPTION)->result();
	}
	function save(){
		$ci=& get_instance();
		$ci->db->set('language_id',$this->getLanguageId());
		$ci->db->set('code',$this->getCode());
		$ci->db->set('sex',$this->getSex());
		$ci->db->insert(TBL_SEX_OPTION);
		return $ci->db->insert_id();
	}
	function update(){
		$ci=& get_instance();
		$ci->db->set('language_id',$this->getLanguageId());
		$ci->db->set('code',$this->getCode());
		$ci->db->set('sex',$this->getSex());
		return $ci->db->where('id', $this->id)->update(TBL_SEX_OPTION);
	}
	function delete($id){
		$ci=& get_instance();
		$ci->db->where('id',$id);
		$ci->db->delete(TBL_SEX_OPTION);
	}
	function deleteByCode($code){
		$ci=& get_instance();
		$ci->db->where('code',$code);
		$ci->db->delete(TBL_SEX_OPTION);
		return $ci->db->affected_rows();
	}
}